<template>
    <div>
        <el-card>
            <h1>{{ "这里是子组件" }}</h1>
            <el-alert :title="msg"></el-alert>
            <el-input v-model="childMsg"></el-input>
            <hr>
            <el-button type="primary" @click="$emit('childClick',childMsg)">你好</el-button>
            <el-button type="primary" @click="sendMsg">发送</el-button>
            <!-- $emit('事件名称','事件的值') -->
        </el-card>
    </div>
</template>
<script>
import { ref } from "vue";
import bus from "vue3-eventbus";
export default {
    name: "Child",
    props: {
        // fuxiangzi传值
        msg: String,
    },
    setup() {
        const childMsg = ref("子组件的值")
        const sendMsg=function () {
            bus.emit('getMsg',childMsg.value)
            // console.log(childMsg.value);
        }
        return {
            childMsg,
            sendMsg
        }
    }
}
</script>
<style></style>